<template>
  <div class="filter">
    <div class="filter_item">
      姓名<Input
        v-model="emplName"
        :maxlength="11"
        show-word-limit
        disabled
        style="width: 300px"
      />
    </div>
    <div class="filter_item">
      性别<Input
        v-model="sex"
        :maxlength="11"
        show-word-limit
        disabled
        style="width: 300px"
      />
    </div>
    <div class="filter_item">
      部门：<Select
        v-model="dept"
        clearable
        style="width: 200px"
        @on-open-change="getDeptList"
        @on-change="deptChange"
      >
        <Option
          v-for="item in deptNames"
          :value="item.deptName"
          :key="item.id"
          >{{ item.deptName }}</Option
        >
      </Select>
    </div>
    <div class="filter_item">
      入职时间：<Input
        v-model="rzdate"
        :maxlength="11"
        show-word-limit
        disabled
        style="width: 300px"
      />
    </div>
    <div class="filter_item">
      转正时间：<DatePicker
        type="date"
        placeholder="Select date"
        @on-change="zzdateChange"
        style="width: 200px"
      ></DatePicker>
    </div>
    <div class="filter_item">
      离职时间：<DatePicker
        type="date"
        placeholder="Select date"
        @on-change="lzdateChange"
        style="width: 200px"
      ></DatePicker>
    </div>
    <div class="filter_item">
      电话：<Input
        v-model="phone"
        :maxlength="11"
        show-word-limit
        clearable
        placeholder="请输入电话"
        style="width: 300px"
      />
    </div>
    <div class="filter_item">
      身份证号码：<Input
        v-model="identy"
        disabled
        :maxlength="18"
        show-word-limit
        clearable
        placeholder="请输出身份证号码"
        style="width: 300px"
      />
    </div>
    <div class="filter_item">
      工号：<Input v-model="emplAcco" disabled clearable style="width: 300px" />
    </div>
    <div class="filter_item">
      密码：<Input
        v-model="password"
        type="password"
        clearable
        placeholder="请输入密码"
        style="width: 300px"
      />
    </div>
    <div>
      <div class="filter_item">
        <Button type="primary" @click="updateEmpl">修改</Button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "updateEmployee",
  data() {
    return {
      emplId: "",
      emplName: "",
      sex: "",
      dept: "",
      deptNames: [],
      phone: "",
      identy: "",
      emplAcco: "",
      password: "",
      rzdate: "",
      zzdate: "",
      lzdate: "",
    };
  },
  methods: {
    getDeptList() {
      this.$axios.post("/api/dept/getAllDept").then((res) => {
        console.log(res.data.data);
        this.deptNames = res.data.data;
      });
    },
    deptChange(e) {
      this.deptName = e;
    },
    zzdateChange(e) {
      this.rzdate = e;
    },
    lzdateChange(e) {
      this.zzdate = e;
    },
    updateEmpl() {
      console.log(this.emplId);
      this.$Modal.confirm({
        title: "提示",
        content: "确定修改？",
        onOk: () => {
          this.$axios
            .post("/api/empl/updateEmpl", {
              deptName: this.deptName,
              lzdate: this.lzdate,
              zzdate: this.zzdate,
              password: this.password,
              phone: this.phone,
              emplId: this.emplId,
            })
            .then((res) => {
              this.$emit("on-close-modal", false);
              console.log(res.data.data);
            });
        },
      });
    },
  },
};
</script>
<style>
</style>